﻿package view
{
    import __AS3__.vec.*;
    import com.core.*;
    import com.core.destroy.*;
    import com.greensock.*;
    import com.sh.game.global.*;
    import com.sh.game.util.*;
    import consts.*;
    import control.*;
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import flash.utils.*;
    import manager.*;
    import morn.core.components.*;
    import morn.core.handlers.*;
    import uiresource.smallmap.*;
    import view.component.*;
    import view.uilt.*;

    public class SmallMapGame extends SmallMapUI
    {
        private var stateDic:Dictionary;
        private var rootRes:String = "png.common.";
        private var btnRoot:String;
        private var musicArr:Array;
        private var viewArr:Array;
        private var _data:Object = "";
        private var _zone:Object = null;
        private var _maskSp:Sprite;
        private var _mapView:Sprite;
        private var _curX:int = 0;
        private var _curY:int = 0;
        private var _mapW:int = 0;
        private var _mapH:int = 0;
        private var _map:Bitmap;
        private var _mapSp:Sprite;
        private var _screenX:int = 0;
        private var _screenY:int = 0;
        private var _mouseThrough:Boolean = false;
        private var _mouseTime:int = 0;
        private var _allActor:Dictionary;
        private var _allScity:Dictionary;
        private var _stageid:int = 0;
        private var _oldstageid:int = 0;
        private var isFirst:Boolean = true;
        private var flag:Boolean = false;
        private var _curMouse:String = null;
        private var _mapPointSp:Sprite;
        private var rateX:Number = 0;
        private var rateY:Number = 0;
        private var _path:Vector.<Bitmap>;
        private var cfgmaps:Array;
        private var cfgtypenewguide:Object;
        private var cfgstage:Object;
        private var _cfgitems:Object;
        private var timeoutID:uint;
        private var cfgOpenLevel:Object;
        private var moveBmd:BitmapData;
        private var endBmd:BitmapData;
        private var mapPointPool:Vector.<MapPoint>;
        private var selfPoint:MapPoint;
        private var _value:Boolean = false;
        private var timeline:TweenMax;
        private var timeline1:TweenMax;
        private var timeline2:TweenMax;
        private var timeline3:TweenMax;
        private var tempCell:Vector.<Bitmap>;
        private static const CLIP_WIDTH:int = 126;
        private static const CLIP_HEIGHT:int = 0;
        private static var STAGE_CELL_WIDTH:int = 48;
        private static var STAGE_CELL_HEIGHT:int = 32;

        public function SmallMapGame()
        {
            var _loc_2:Object = null;
            var _loc_3:Object = null;
            var _loc_4:Boolean = false;
            this.stateDic = new Dictionary();
            this.btnRoot = this.rootRes + "btn_";
            this.musicArr = [{value:"屏蔽背景音乐", cbName:"bgm", main:"setbgmusic"}, {value:"屏蔽基础音效", cbName:"offbasesound", main:"setsound"}, {value:"屏蔽技能音效", cbName:"offskillsound"}];
            this.viewArr = [{value:"隐藏玩家", cbName:"hideplayer", zoneOption:"hideplayer"}, {value:"隐藏怪物", cbName:"hidemonster", zoneOption:"hidemonster"}, {value:"隐藏全部技能特效", cbName:"hideallskill"}, {value:"隐藏场景特效", cbName:"hidestageeffect", zoneOption:"hidestageeffect"}, {value:"隐藏行会名称", cbName:"hideunion", zoneOption:"hideunion"}, {value:"隐藏同帮成员", cbName:"hideunionplayer", zoneOption:"hideunionplayer"}, {value:"隐藏角色翅膀", cbName:"hidewing", zoneOption:"hidewing"}, {value:"隐藏法神", cbName:"hidefashen", zoneOption:"hidefashen"}];
            this._mapSp = new Sprite();
            this._allActor = new Dictionary();
            this._allScity = new Dictionary();
            this._mapPointSp = new Sprite();
            this.cfgmaps = ConfigDictionary.data.maplist;
            this.cfgtypenewguide = ConfigDictionary.data.typenewguide;
            this.cfgOpenLevel = ConfigDictionary.data.openlevel;
            this.mapPointPool = new Vector.<MapPoint>;
            this.tempCell = new Vector.<Bitmap>;
            this.stateDic["btn_show"] = true;
            this.stateDic["btn_music"] = 0;
            this.stateDic["btn_view"] = 0;
            var _loc_1:* = ModelProxy.getValue("localCache", "option");
            for each (_loc_2 in this.musicArr)
            {
                
                this.stateDic["btn_music"] = this.stateDic["btn_music"] + int(_loc_1[_loc_2.cbName]);
            }
            for each (_loc_3 in this.viewArr)
            {
                
                this.stateDic["btn_view"] = this.stateDic["btn_view"] + int(_loc_1[_loc_3.cbName]);
            }
            _loc_4 = Boolean(this.stateDic["btn_music"]);
            btn_music.skin = this.btnRoot + (_loc_4 ? ("music_close") : ("music_open"));
            _loc_4 = Boolean(this.stateDic["btn_view"]);
            btn_view.skin = this.btnRoot + (_loc_4 ? ("function_close") : ("function_open"));
            this._maskSp = new Sprite();
            this._maskSp.graphics.beginFill(16777215, 1);
            this._maskSp.graphics.drawCircle(63, 0, 63);
            this._maskSp.graphics.endFill();
            this._mapView = new Sprite();
            this._mapView.mask = this._maskSp;
            var _loc_6:int = 51;
            this._maskSp.x = 51;
            this._mapView.x = _loc_6;
            var _loc_6:int = 102;
            this._maskSp.y = 102;
            this._mapView.y = _loc_6;
            box_map.addChildAt(this._mapView, 1);
            box_map.addChild(this._maskSp);
            this._mapView.addChild(this._mapSp);
            this._mapView.addChild(this._mapPointSp);
            this._mapPointSp.mouseEnabled = false;
            var _loc_5:* = Control.create(MiniMapControl, this);
            ModelProxy.addObserver("minimap", _loc_5);
            this.initEvent();
            activeShan.alpha = 0;
            huodongShan.alpha = 0;
            chengjiuShan.alpha = 0;
            return;
        }// end function

        public function initEvent() : void
        {
            btn_show.clickHandler = new Handler(this.doClick, ["btn_show"]);
            btn_unshow.clickHandler = new Handler(this.doClick, ["btn_unshow"]);
            btn_music.clickHandler = new Handler(this.doClick, ["btn_music"]);
            btn_view.clickHandler = new Handler(this.doClick, ["btn_view"]);
            btn_email.clickHandler = new Handler(this.doClick, ["btn_email"]);
            btn_rank.clickHandler = new Handler(this.doClick, ["btn_rank"]);
            btn_achievement.clickHandler = new Handler(this.doClick, ["btn_achievement"]);
            btn_activity.clickHandler = new Handler(this.doClick, ["btn_activity"]);
            btn_huodong.clickHandler = new Handler(this.doClick, ["btn_huodong"]);
            btn_map.clickHandler = new Handler(this.doClick, ["btn_map"]);
            btn_newh.clickHandler = new Handler(this.doClick, ["btn_newh"]);
            this.addEventListener(MouseEvent.MOUSE_DOWN, this.doStop);
            btn_view.addEventListener(MouseEvent.ROLL_OVER, this.doMouse);
            btn_music.addEventListener(MouseEvent.ROLL_OVER, this.doMouse);
            box_select.addEventListener(MouseEvent.ROLL_OVER, this.doMouse);
            btn_show.addEventListener(MouseEvent.ROLL_OVER, this.doMouse);
            btn_unshow.addEventListener(MouseEvent.ROLL_OVER, this.doMouse);
            btn_map.addEventListener(MouseEvent.ROLL_OVER, this.doMouse);
            btn_map.addEventListener(MouseEvent.ROLL_OUT, this.doMouse);
            btn_unshow.addEventListener(MouseEvent.ROLL_OUT, this.doMouse);
            btn_show.addEventListener(MouseEvent.ROLL_OUT, this.doMouse);
            btn_view.addEventListener(MouseEvent.ROLL_OUT, this.doMouse);
            btn_music.addEventListener(MouseEvent.ROLL_OUT, this.doMouse);
            box_select.addEventListener(MouseEvent.ROLL_OUT, this.doMouse);
            btn_rank.addEventListener(MouseEvent.ROLL_OVER, this.doMouse);
            btn_rank.addEventListener(MouseEvent.ROLL_OUT, this.doMouse);
            btn_achievement.addEventListener(MouseEvent.ROLL_OVER, this.doMouse);
            btn_achievement.addEventListener(MouseEvent.ROLL_OUT, this.doMouse);
            btn_huodong.addEventListener(MouseEvent.ROLL_OVER, this.doMouse);
            btn_huodong.addEventListener(MouseEvent.ROLL_OUT, this.doMouse);
            btn_activity.addEventListener(MouseEvent.ROLL_OVER, this.doMouse);
            btn_activity.addEventListener(MouseEvent.ROLL_OUT, this.doMouse);
            btn_email.addEventListener(MouseEvent.ROLL_OVER, this.doMouse);
            btn_email.addEventListener(MouseEvent.ROLL_OUT, this.doMouse);
            btn_newh.addEventListener(MouseEvent.ROLL_OVER, this.doMouse);
            btn_newh.addEventListener(MouseEvent.ROLL_OUT, this.doMouse);
            list_select.renderHandler = new Handler(this.selectHandler);
            this._mapSp.addEventListener(MouseEvent.CLICK, this.mapClickHandler);
            UIVisibleManager.instance.register("smallmap", box_map, UIVisibleManager.VUp);
            return;
        }// end function

        protected function doMouse(event:MouseEvent) : void
        {
            switch(event.type)
            {
                case MouseEvent.ROLL_OVER:
                {
                    switch(event.currentTarget.name)
                    {
                        case "btn_music":
                        {
                            box_select.visible = true;
                            box_select.x = 30;
                            box_select.y = 78;
                            img_bg.height = 85;
                            list_select.array = this.musicArr;
                            this._mouseThrough = false;
                            this._curMouse = "btn_music";
                            break;
                        }
                        case "btn_view":
                        {
                            box_select.visible = true;
                            box_select.x = 20;
                            box_select.y = 38;
                            img_bg.height = 195;
                            list_select.repeatY = this.viewArr.length;
                            list_select.array = this.viewArr;
                            this._mouseThrough = false;
                            this._curMouse = "btn_view";
                            break;
                        }
                        case "box_select":
                        {
                            this._mouseThrough = false;
                            break;
                        }
                        case "btn_open":
                        {
                            ModelProxy.change("tips", "normal", "点击打开活动");
                            break;
                        }
                        case "btn_rank":
                        {
                            ModelProxy.change("tips", "normal", "点击打开排行");
                            break;
                        }
                        case "btn_close":
                        {
                            ModelProxy.change("tips", "normal", "点击隐藏活动");
                            break;
                        }
                        case "btn_show":
                        {
                            ModelProxy.change("tips", "normal", "点击打开小地图");
                            break;
                        }
                        case "btn_unshow":
                        {
                            ModelProxy.change("tips", "normal", "点击隐藏小地图");
                            break;
                        }
                        case "btn_map":
                        {
                            ModelProxy.change("tips", "normal", "点击打开地图");
                            break;
                        }
                        case "btn_activity":
                        {
                            ModelProxy.change("tips", "normal", "点击打开活跃度");
                            break;
                        }
                        case "btn_achievement":
                        {
                            ModelProxy.change("tips", "normal", "点击打开成就");
                            break;
                        }
                        case "btn_huodong":
                        {
                            ModelProxy.change("tips", "normal", "点击打开每日活动");
                            break;
                        }
                        case "btn_email":
                        {
                            ModelProxy.change("tips", "normal", "点击打开邮件");
                            break;
                        }
                        case "btn_newh":
                        {
                            ModelProxy.change("tips", "normal", "点击打开新手指南");
                            break;
                        }
                        default:
                        {
                            break;
                        }
                    }
                    break;
                }
                case MouseEvent.ROLL_OUT:
                {
                    if (this._mouseTime)
                    {
                        clearTimeout(this._mouseTime);
                    }
                    this._mouseTime = 0;
                    this._mouseTime = setTimeout(this.checkShow, 300);
                    this._mouseThrough = true;
                    ModelProxy.change("tips", "state", "close");
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        private function checkShow() : void
        {
            clearTimeout(this._mouseTime);
            this._mouseTime = 0;
            if (this._mouseThrough)
            {
                this._curMouse = null;
                box_select.visible = false;
            }
            return;
        }// end function

        private function selectHandler(param1:Component, param2:int) : void
        {
            var _loc_3:Object = null;
            var _loc_4:CheckBox = null;
            if (param2 < list_select.length)
            {
                _loc_3 = list_select.array[param2];
                _loc_4 = param1.getChildByName("cb_box") as CheckBox;
                _loc_4.selected = ModelProxy.getValue("localCache", "option." + _loc_3.cbName);
                _loc_4.clickHandler = new Handler(this.cbHandler, [_loc_4, _loc_3]);
                _loc_4.label = _loc_3.value;
            }
            return;
        }// end function

        private function cbHandler(param1:CheckBox, param2:Object) : void
        {
            var _loc_3:Boolean = false;
            ModelProxy.change("localCache", "updateOption", {key:param2.cbName, data:int(param1.selected)});
            this.doCb(param1.selected, param2);
            if (this._curMouse)
            {
                this.stateDic[this._curMouse] = this.stateDic[this._curMouse] + (param1.selected == 0 ? (-1) : (1));
                switch(this._curMouse)
                {
                    case "btn_music":
                    {
                        _loc_3 = Boolean(this.stateDic[this._curMouse]);
                        btn_music.skin = this.btnRoot + (_loc_3 ? ("music_close") : ("music_open"));
                        break;
                    }
                    case "btn_view":
                    {
                        _loc_3 = Boolean(this.stateDic[this._curMouse]);
                        btn_view.skin = this.btnRoot + (_loc_3 ? ("function_close") : ("function_open"));
                        break;
                    }
                    default:
                    {
                        break;
                    }
                }
            }
            return;
        }// end function

        private function doCb(param1:Boolean, param2:Object) : void
        {
            if (param2.main)
            {
                ModelProxy.change("main", param2.main, param1);
            }
            if (param2.zoneOption)
            {
                ModelProxy.change("zoneOption", param2.zoneOption, param1);
            }
            return;
        }// end function

        protected function doOpen(event:MouseEvent) : void
        {
            ModelProxy.change("mainui", "changeActive", true);
            return;
        }// end function

        protected function doStop(event:MouseEvent) : void
        {
            return;
        }// end function

        private function doClick(param1:String) : void
        {
            var _loc_2:Point = null;
            var _loc_3:Boolean = false;
            var _loc_4:Object = null;
            var _loc_5:int = 0;
            var _loc_6:int = 0;
            switch(param1)
            {
                case "btn_show":
                {
                    UIVisibleManager.instance.Hiddern("smallmap");
                    var _loc_7:Boolean = true;
                    btn_unshow.visible = true;
                    this.stateDic[param1] = _loc_7;
                    btn_show.visible = false;
                    break;
                }
                case "btn_unshow":
                {
                    UIVisibleManager.instance.Hiddern("smallmap");
                    var _loc_7:Boolean = true;
                    btn_show.visible = true;
                    this.stateDic[param1] = _loc_7;
                    btn_unshow.visible = false;
                    break;
                }
                case "btn_music":
                {
                    this.setMusic();
                    break;
                }
                case "btn_email":
                {
                    PluginManager.instance.changePlugin("email", btn_email.localToGlobal(new Point(0, 0)));
                    ModelProxy.change("mainview", "hidemail", null);
                    this.stopEmail();
                    break;
                }
                case "btn_view":
                {
                    this.stateDic[param1] = this.stateDic[param1] == 0 ? (5) : (0);
                    _loc_3 = Boolean(this.stateDic[param1]);
                    this.changeAllSelect(this.viewArr, _loc_3, 2);
                    list_select.refresh();
                    btn_view.skin = this.btnRoot + (_loc_3 ? ("function_close") : ("function_open"));
                    break;
                }
                case "btn_close":
                {
                    ModelProxy.change("mainui", "changeActive", false);
                    break;
                }
                case "btn_map":
                {
                    _loc_2 = this.localToGlobal(new Point(btn_map.x, btn_map.y));
                    ModelProxy.change("plugin", "change", {target:"map", point:_loc_2});
                    break;
                }
                case "btn_rank":
                {
                    _loc_2 = this.localToGlobal(new Point(btn_rank.x, btn_rank.y));
                    ModelProxy.change("plugin", "change", {target:"rank", point:_loc_2});
                    break;
                }
                case "btn_achievement":
                {
                    this.stopCj();
                    _loc_2 = this.localToGlobal(new Point(btn_achievement.x, btn_achievement.y));
                    ModelProxy.change("plugin", "change", {target:"achievement", point:_loc_2});
                    break;
                }
                case "btn_huodong":
                {
                    this.stopActive();
                    _loc_4 = ModelProxy.getValue("data", "user");
                    _loc_5 = _loc_4.level;
                    _loc_6 = _loc_4.rein;
                    if (_loc_6 > int(this.cfgOpenLevel["everyday"][0].rein))
                    {
                        _loc_2 = this.localToGlobal(new Point(btn_huodong.x, btn_huodong.y));
                        ModelProxy.change("plugin", "change", {target:"everyday", point:_loc_2});
                    }
                    else if (_loc_6 == int(this.cfgOpenLevel["everyday"][0].rein) && _loc_5 >= int(this.cfgOpenLevel["everyday"][0].level))
                    {
                        _loc_2 = this.localToGlobal(new Point(btn_huodong.x, btn_huodong.y));
                        ModelProxy.change("plugin", "change", {target:"everyday", point:_loc_2});
                    }
                    else
                    {
                        ItemUilt.ErrortipsForLevel(this.cfgOpenLevel["everyday"][0].level);
                    }
                    break;
                }
                case "btn_activity":
                {
                    _loc_2 = this.localToGlobal(new Point(btn_activity.x, btn_activity.y));
                    ModelProxy.change("plugin", "change", {target:"active", point:_loc_2});
                    this.stopHuoyue();
                    break;
                }
                case "btn_newh":
                {
                    ModelProxy.change("plugin", "open", {target:"gameactive"});
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        private function changeAllSelect(param1:Array, param2:Boolean, param3:int) : void
        {
            var _loc_5:Object = null;
            var _loc_4:Array = [];
            for each (_loc_5 in param1)
            {
                
                _loc_4.push({key:_loc_5.cbName, data:param2});
                this.doCb(param2, _loc_5);
            }
            ModelProxy.change("localCache", "updateOption", _loc_4);
            if (param2 == false)
            {
                if (param3 == 2)
                {
                    ModelProxy.change("zoneOption", "hidewing", false);
                }
            }
            return;
        }// end function

        public function updateMap(param1:Object) : void
        {
            var _loc_3:Object = null;
            var _loc_4:Object = null;
            var _loc_5:String = null;
            var _loc_6:Object = null;
            var _loc_7:String = null;
            var _loc_8:TransPoint = null;
            var _loc_9:String = null;
            var _loc_10:MapPoint = null;
            var _loc_11:Boolean = false;
            var _loc_12:Array = null;
            var _loc_13:int = 0;
            var _loc_2:* = param1.mapid;
            if (!this._zone || this._zone.id != _loc_2)
            {
                _loc_4 = ConfigDictionary.data.maplist;
                _loc_5 = null;
                if (this._zone)
                {
                    _loc_5 = this._zone.img;
                }
                if (_loc_4)
                {
                    this._zone = _loc_4[_loc_2];
                }
                if (!this._zone)
                {
                    this._zone = {id:1, width:5980, height:4745};
                }
                _loc_6 = param1.safes;
                _loc_7 = "assets/images/minimap/" + this._zone.img + ".jpg";
                App.mloader3.loadBMD(Config.getUrl(_loc_7), 1, new Handler(this.onComp), null, null, false);
                for each (_loc_8 in this._allScity)
                {
                    
                    _loc_8.dispose();
                }
                DestroyUtil.destroyMap(this._allScity);
                for (_loc_9 in param1.trans)
                {
                    
                    this._allScity[_loc_9] = this.addTrans(param1.trans[_loc_9]);
                }
            }
            for each (_loc_3 in param1.roles)
            {
                
                if (this._allActor[_loc_3.id])
                {
                    _loc_10 = this._allActor[_loc_3.id];
                    _loc_10.x = _loc_3.x * this.rateX;
                    _loc_10.y = _loc_3.y * this.rateY;
                    if (_loc_3.isMe())
                    {
                        this._data = _loc_3.gameObj.baseObj;
                        txt_pos.text = int(this._data.x) + "," + int(this._data.y);
                        this.stageid = _loc_3.gameObj.baseObj.mapid;
                        _loc_10.dir = _loc_3.dir;
                        if (_loc_3.gameObj.baseObj.mapid == 16005)
                        {
                            ModelProxy.change("mainuiInstance", "fuckPoint", new Point(this._data.x, this._data.y));
                        }
                    }
                    else
                    {
                        _loc_11 = false;
                        if (_loc_3.gameObj.baseObj)
                        {
                            _loc_12 = ModelProxy.getValue("data", "teams");
                            if (_loc_12)
                            {
                                _loc_13 = 0;
                                while (_loc_13 < _loc_12.length)
                                {
                                    
                                    if (_loc_12[_loc_13] == _loc_3.gameObj.baseObj.rid)
                                    {
                                        _loc_11 = true;
                                        break;
                                    }
                                    _loc_13++;
                                }
                            }
                        }
                        _loc_10.teamPlayer = _loc_11;
                    }
                    if (_loc_3.mine || !_loc_3.gameObj.baseObj.yinsh)
                    {
                        if (!_loc_10.visible)
                        {
                            _loc_10.visible = true;
                        }
                        continue;
                    }
                    if (_loc_10.visible)
                    {
                        _loc_10.visible = false;
                    }
                }
            }
            this._curX = param1.x;
            this._curY = param1.y;
            this.updateMapPos();
            return;
        }// end function

        private function addTrans(param1:Object) : TransPoint
        {
            var _loc_2:* = new TransPoint(this._mapPointSp, param1);
            _loc_2.setpivotXY(param1.cellX * this.rateX * 48, param1.cellY * this.rateY * 32);
            return _loc_2;
        }// end function

        private function onComp(param1:BitmapData) : void
        {
            var _loc_2:MapPoint = null;
            var _loc_3:TransPoint = null;
            if (this._map)
            {
                this._map.bitmapData.dispose();
                this._map = null;
            }
            if (param1 == null)
            {
                return;
            }
            var _loc_4:* = new Bitmap(param1.clone());
            this._map = new Bitmap(param1.clone());
            this._mapSp.addChild(_loc_4);
            this._mapW = this._map.width;
            this._mapH = this._map.height;
            this.rateX = this._mapW / this._zone.width;
            this.rateY = this._mapH / this._zone.height;
            for each (_loc_2 in this._allActor)
            {
                
                _loc_2.x = _loc_2.gameObj.x * this.rateX;
                _loc_2.y = _loc_2.gameObj.y * this.rateY;
            }
            for each (_loc_3 in this._allScity)
            {
                
                _loc_3.setpivotXY(_loc_3.gameObj.cellX * this.rateX * 48, _loc_3.gameObj.cellY * this.rateY * 32);
            }
            this.updateMapPos();
            return;
        }// end function

        private function updateMapPos() : void
        {
            if (!this._zone)
            {
                return;
            }
            var _loc_1:* = this._curX * this._mapW / this._zone.width;
            var _loc_2:* = this._curY * this._mapH / this._zone.height;
            this._screenX = int(CLIP_WIDTH / 2) - _loc_1;
            this._screenY = int(CLIP_HEIGHT / 2) - _loc_2;
            if (this._screenX > 0)
            {
                this._screenX = 0;
            }
            if (this._screenX < CLIP_WIDTH - this._mapW)
            {
                this._screenX = CLIP_WIDTH - this._mapW;
            }
            if (this._screenY < CLIP_HEIGHT - this._mapH)
            {
                this._screenY = CLIP_HEIGHT - this._mapH;
            }
            if (this._screenY > 0)
            {
                this._screenY = 0;
            }
            if (this._map)
            {
                this._map.x = this._screenX;
                this._mapPointSp.x = this._screenX;
                if (this._screenY > -65)
                {
                    this._map.y = -65;
                }
                else if (this._screenY < -this._mapH + 65)
                {
                    this._map.y = -this._mapH + 65;
                }
                else
                {
                    this._map.y = this._screenY;
                }
                if (this._screenY > -65)
                {
                    this._mapPointSp.y = -65;
                }
                else if (this._screenY < -this._mapH + 65)
                {
                    this._mapPointSp.y = -this._mapH + 65;
                }
                else
                {
                    this._mapPointSp.y = this._screenY;
                }
            }
            return;
        }// end function

        public function eleAdd(param1:Object) : void
        {
            if (param1)
            {
                this._allActor[param1.id] = this.addActor(param1);
            }
            return;
        }// end function

        private function addActor(param1:Object) : MapPoint
        {
            var _loc_4:MapPoint = null;
            var _loc_5:Array = null;
            var _loc_6:int = 0;
            var _loc_2:Boolean = false;
            if (param1.isMe())
            {
                this._data = param1.gameObj.baseObj;
                txt_pos.text = int(this._data.x) + "," + int(this._data.y);
                this.stageid = param1.gameObj.baseObj.mapid;
                _loc_2 = true;
            }
            var _loc_3:Boolean = false;
            if (param1.gameObj.baseObj)
            {
                _loc_5 = ModelProxy.getValue("data", "teams");
                if (_loc_5)
                {
                    _loc_6 = 0;
                    while (_loc_6 < _loc_5.length)
                    {
                        
                        if (_loc_5[_loc_6] == param1.gameObj.baseObj.rid)
                        {
                            _loc_3 = true;
                            break;
                        }
                        _loc_6++;
                    }
                }
            }
            if (_loc_2)
            {
                if (this.selfPoint != null)
                {
                    _loc_4 = this.selfPoint;
                    _loc_4.changeSelf(this._mapPointSp, param1);
                }
                else
                {
                    _loc_4 = new MapPoint(this._mapPointSp, param1, _loc_3);
                    this.selfPoint = _loc_4;
                }
            }
            else if (this.mapPointPool.length > 0)
            {
                _loc_4 = this.mapPointPool.shift();
                _loc_4.changeOther(this._mapPointSp, param1, _loc_3);
            }
            else
            {
                _loc_4 = new MapPoint(this._mapPointSp, param1, _loc_3);
            }
            _loc_4.x = param1.x * this.rateX;
            _loc_4.y = param1.y * this.rateY;
            return _loc_4;
        }// end function

        public function unFold(param1:Boolean) : void
        {
            this._value = param1;
            if (this._value || this._stageid == 1001)
            {
                ModelProxy.change("data", "issafe", true);
                ModelProxy.change("movetips", "error1", {data:"进入安全区域", color:MColor.New65});
                txt_safe.text = "安全区域";
                txt_safe.color = 5485622;
            }
            else
            {
                ModelProxy.change("data", "issafe", false);
                ModelProxy.change("movetips", "error1", {data:"离开安全区域", color:MColor.New56});
                txt_safe.text = "危险区域";
                txt_safe.color = 13051156;
            }
            return;
        }// end function

        public function eleRemove(param1:Object) : void
        {
            var _loc_2:* = this._allActor[param1];
            if (_loc_2)
            {
                _loc_2.dispose();
                delete this._allActor[param1];
                if (_loc_2.isSelf == false)
                {
                    this.mapPointPool.push(_loc_2);
                }
            }
            return;
        }// end function

        public function clearPath() : void
        {
            var _loc_1:Bitmap = null;
            if (this._path)
            {
                while (this._path.length > 0)
                {
                    
                    _loc_1 = this._path.shift();
                    _loc_1.parent.removeChild(_loc_1);
                }
            }
            return;
        }// end function

        public function checkPath(param1:int) : void
        {
            var _loc_2:Bitmap = null;
            if (this._path)
            {
                while (this._path.length > param1)
                {
                    
                    _loc_2 = this._path.shift();
                    _loc_2.parent.removeChild(_loc_2);
                }
                this.tempCell = this._path;
            }
            this._path = new Vector.<Bitmap>;
            return;
        }// end function

        public function findPath(param1:Vector.<Point>) : void
        {
            var _loc_5:Point = null;
            var _loc_6:Bitmap = null;
            var _loc_7:Point = null;
            var _loc_2:int = 2;
            if (this.rateX < 0.04)
            {
                _loc_2 = 6;
            }
            else if (this.rateX < 0.05)
            {
                _loc_2 = 5;
            }
            else if (this.rateX < 0.06)
            {
                _loc_2 = 4;
            }
            else if (this.rateX < 0.07)
            {
                _loc_2 = 3;
            }
            var _loc_3:* = param1.length - 1;
            var _loc_4:int = 0;
            while (_loc_3 >= 0)
            {
                
                _loc_4++;
                _loc_3 = _loc_3 - _loc_2;
            }
            _loc_3 = param1.length - 1;
            this.checkPath(_loc_4);
            if (this.moveBmd == null)
            {
                this.moveBmd = App.asset.getBitmapData("png.common.move_point");
            }
            if (this.endBmd == null)
            {
                this.endBmd = App.asset.getBitmapData("png.common.end_point");
            }
            while (_loc_3 >= 0)
            {
                
                _loc_5 = param1[_loc_3];
                if (this.tempCell.length > 0)
                {
                    _loc_6 = this.tempCell.shift();
                    _loc_6.bitmapData = _loc_3 == (param1.length - 1) ? (this.endBmd) : (this.moveBmd);
                }
                else
                {
                    _loc_6 = _loc_3 == (param1.length - 1) ? (new Bitmap(this.endBmd)) : (new Bitmap(this.moveBmd));
                    this._mapPointSp.addChild(_loc_6);
                }
                this._path.push(_loc_6);
                _loc_7 = this.changeCellToMiniXY(_loc_5.x, _loc_5.y);
                _loc_6.x = _loc_7.x;
                _loc_6.y = _loc_7.y;
                _loc_3 = _loc_3 - _loc_2;
            }
            return;
        }// end function

        private function changeCellToMiniXY(param1:int, param2:int) : Point
        {
            var _loc_3:* = new Point();
            _loc_3.x = int((param1 * STAGE_CELL_WIDTH + STAGE_CELL_WIDTH * 0.5) * this.rateX);
            _loc_3.y = int((param2 * STAGE_CELL_HEIGHT + STAGE_CELL_HEIGHT * 0.5) * this.rateY);
            return _loc_3;
        }// end function

        private function changeMiniXYToCell(param1:int, param2:int) : Point
        {
            var _loc_3:* = new Point();
            _loc_3.x = int(((param1 - this._map.x) / this.rateX - STAGE_CELL_WIDTH * 0.5) / STAGE_CELL_WIDTH);
            _loc_3.y = int(((param2 - this._map.y) / this.rateY - STAGE_CELL_HEIGHT * 0.5) / STAGE_CELL_HEIGHT);
            return _loc_3;
        }// end function

        private function mapClickHandler(event:MouseEvent) : void
        {
            ModelProxy.change("zone", "stopGuaji", null);
            var _loc_2:* = event.stageX;
            var _loc_3:* = event.stageY;
            var _loc_4:* = this._mapSp.globalToLocal(new Point(_loc_2, _loc_3));
            var _loc_5:* = this.changeMiniXYToCell(_loc_4.x, _loc_4.y);
            ModelProxy.change("zone", "autoMove", {x:_loc_5.x, y:_loc_5.y, onhorse:true});
            return;
        }// end function

        public function hideSome() : void
        {
            this.changeAllSelect(this.viewArr, false, 2);
            return;
        }// end function

        public function setMusic() : void
        {
            this.stateDic["btn_music"] = this.stateDic["btn_music"] == 0 ? (3) : (0);
            var _loc_1:* = Boolean(this.stateDic["btn_music"]);
            this.changeAllSelect(this.musicArr, _loc_1, 1);
            list_select.refresh();
            btn_music.skin = this.btnRoot + (_loc_1 ? ("music_close") : ("music_open"));
            return;
        }// end function

        public function set stageid(param1:int) : void
        {
            var bgmusic:int;
            var obj:Object;
            var value:* = param1;
            if (this._stageid == value)
            {
                return;
            }
            this._stageid = value;
            var cityname:* = this.cfgmaps[this._stageid].name;
            txt_place.text = cityname;
            var options:* = ModelProxy.getValue("localCache", "option");
            bgmusic;
            if (options)
            {
                bgmusic = int(options["bgm"]);
            }
            if (this.flag)
            {
                if (bgmusic == 0)
                {
                    ModelProxy.change("main", "changebgmusic", this._stageid);
                }
            }
            else if (this.isFirst)
            {
                TimeOutManager.getInstance().setTimer(function () : void
            {
                if (bgmusic == 0)
                {
                    ModelProxy.change("main", "changebgmusic", _stageid);
                }
                flag = true;
                return;
            }// end function
            , 60000);
            }
            if (this._stageid != 1027)
            {
                ModelProxy.change("mainui", "hidemonsterpanel", null);
            }
            ModelProxy.change("newguide", "hide", 0);
            if (this._oldstageid == 16001)
            {
                ModelProxy.change("guide", "hide", 0);
            }
            if (this._stageid > 10000)
            {
                ModelProxy.change("guidepao", "hide", GuideType.GUIDE_XY4);
            }
            if (this.cfgstage == null && this.cfgtypenewguide[4])
            {
                this.cfgstage = new Array();
                var _loc_3:int = 0;
                var _loc_4:* = this.cfgtypenewguide[4];
                while (_loc_4 in _loc_3)
                {
                    
                    obj = _loc_4[_loc_3];
                    this.cfgstage[obj.typeparam] = obj;
                }
            }
            if (this.cfgstage[this._stageid])
            {
                GuideView.getInstance().doGuide(this.cfgstage[this._stageid].id);
            }
            this._oldstageid = this._stageid;
            return;
        }// end function

        public function playEmail() : void
        {
            return;
        }// end function

        public function stopEmail() : void
        {
            return;
        }// end function

        public function playActive() : void
        {
            return;
        }// end function

        public function stopActive() : void
        {
            return;
        }// end function

        public function playHuoyue() : void
        {
            if (this.timeline2)
            {
                this.timeline2.kill();
            }
            activeShan.alpha = 0;
            this.timeline2 = TweenMax.to(activeShan, 1, {alpha:1, repeat:int.MAX_VALUE, yoyo:true});
            return;
        }// end function

        public function stopHuoyue() : void
        {
            if (this.timeline2)
            {
                this.timeline2.kill();
            }
            activeShan.alpha = 0;
            return;
        }// end function

        public function playCj() : void
        {
            if (this.timeline3)
            {
                this.timeline3.kill();
            }
            chengjiuShan.alpha = 0;
            this.timeline3 = TweenMax.to(chengjiuShan, 1, {alpha:1, repeat:int.MAX_VALUE, yoyo:true});
            return;
        }// end function

        public function stopCj() : void
        {
            if (this.timeline3)
            {
                this.timeline3.kill();
            }
            chengjiuShan.alpha = 0;
            return;
        }// end function

    }
}
